<?php

namespace app\admin\controller;

use app\admin\BaseController;
use app\admin\model\ProjectIntroModel;

class ProjectStat extends BaseController
{
    public function query()
    {
        $projectIntroModel = ProjectIntroModel::where('village_id',$this->villageId)->find();
        return show($projectIntroModel);
    }

    public function edit()
    {
        $params = $this->request->param();
        $projectIntroModel = ProjectIntroModel::where('village_id',$this->villageId)->find();

        if ($projectIntroModel === null) {
            $params['village_id'] = $this->villageId;
            ProjectIntroModel::create($params);
        } else {
            $projectIntroModel->xmsl = $params['xmsl'];
            $projectIntroModel->ykgxm = $params['ykgxm'];
            $projectIntroModel->xmkgl = $params['xmkgl'];
            $projectIntroModel->tze = $params['tze'];
            $projectIntroModel->tzwcl = $params['tzwcl'];
            $projectIntroModel->save();
        }

        return show();
    }
}